package vn.egame.elockscreen.tools;

import java.util.Calendar;

import android.content.Context;
import vn.egame.elockscreen.ELockscreenPreferences;
import vn.egame.elockscreen.R;

public class TimerManager {

	public static final String MONTH[] = new String[] { "January", "February",
			"March", "April", "May", "June", "July", "August", "September",
			"October", "November", "December" };

	// public static final String DAY_OF_WEEK[] = new String[] { "Sunday",
	// "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
	// "" };

	private static String[] DAY_OF_WEEK;

	private static TimerManager INSTANCE;

	TimerManager() {
		// Do nothing...
	}

	// Obtain the LiveWallpaperPreferences instance
	public static TimerManager getInstance() {
		if (INSTANCE == null) {
			INSTANCE = new TimerManager();
		}
		return INSTANCE;
	}

	public void init(Context pContext) {
		DAY_OF_WEEK = pContext.getResources().getStringArray(
				R.array.day_of_week);
	}

	public static String getDate() {

		String dayOfMonth = Integer.toString(Calendar.getInstance().get(
				Calendar.DAY_OF_MONTH));
		if (dayOfMonth.length() == 1)
			dayOfMonth = "0" + dayOfMonth;

		String dayOfWeek = DAY_OF_WEEK[Calendar.getInstance().get(
				Calendar.DAY_OF_WEEK)];

		String month = Integer.toString(Calendar.getInstance().get(
				Calendar.MONTH) + 1);
		if (month.length() == 1)
			month = "0" + month;

		String year = Integer.toString(Calendar.getInstance()
				.get(Calendar.YEAR));

		return dayOfMonth + "/" + month + "/" + year + " " + dayOfWeek;

	}

	public static String getMonth() {
		return MONTH[Calendar.getInstance().get(Calendar.MONTH)];
	}

	public static String getTime() {
		String str1 = Integer.toString(Calendar.getInstance().get(
				Calendar.HOUR_OF_DAY));
		if (str1.length() == 1)
			str1 = "0" + str1;
		String str2 = Integer.toString(Calendar.getInstance().get(
				Calendar.MINUTE));
		if (str2.length() == 1)
			str2 = "0" + str2;
		return str1 + ":" + str2;
	}

	public static String getAM() {
		if (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 12) {
			return "am";
		}
		return "pm";
	}
}